<?PHP
  class MenuListWidget extends WidgetBase{
    public function load(){
      $this->headline = "Men&uuml;s";
      if(Cache::contains("menu","widget_".$_GET['dir'])){
        $this->content = Cache::getData("menu","widget_".$_GET['dir']);
      }
      else{
        if(!isset($_GET['dir']) || substr($_GET['dir'],0,1) == '.') $_GET['dir'] = "";
        $template = new Template();
        $template->load("plugin_menulistwidget_menulist");
        $template->assign_var("NEWMENUURL",Settings::getInstance()->get("host")."admin/newmenu.html");
        $menus = sys::getMenues($_GET['dir']);
        foreach($menus as $menu){
          $index = $template->add_loop_item("MENUS");
	      $template->assign_loop_var("MENUS", $index, "ID", $menu->id);
	      $template->assign_loop_var("MENUS", $index, "TITLE", $menu->name);
	      $template->assign_loop_var("MENUS", $index, "PAGES", $menu->count);
	      $template->assign_loop_var("MENUS", $index, "EDITURL", Settings::getInstance()->get("host")."admin/editmenu.html?menu=".$menu->id);
	      $template->assign_loop_var("MENUS", $index, "DELETEURL", Settings::getInstance()->get("host")."admin/deletemenu.html?menu=".$menu->id);
        }
        if(!$menus){
          $template->assign_var("NOMENUS","Es sind keine Men&uuml;s vorhanden.");
        }
        else{
          $template->assign_var("NOMENUS","");
        }
        $this->content = $template->getCode();
        Cache::setData("menu","widget_".$_GET['dir'],$this->content);
      }
    }
  }
?>